<?php

namespace app\common\util;

class CacheUtil
{
    public static function set($bucket, $name, $value)
    {
        $allKeys = cache($bucket);
        if (!$allKeys) {
            $allKeys = [];
        }
        $allKeys = array_merge($allKeys,[$name=>$value]);
        cache($bucket, $allKeys);
        return true;
    }

    public static function get($bucket, $name, $default)
    {
        $allKeys =  cache($bucket);
        return $allKeys[$name]??$default;
    }
}